import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport, { VantResolve } from 'vite-plugin-style-import'
const path = require('path');

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    styleImport({
      resolves: [VantResolve()],
      libs: [
        {
          libraryName: "vant",
          esModule: true,
          resolveStyle: (name) => {
            return `../node_modules/vant/es/${name}/style/index`;
          },
        },
      ]
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  server:{
    host: '0.0.0.0',
    proxy:{
      '^/api':{
        target:'http://192.168.1.72:8084',
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/api/,'')
      },
      '^/nyuwa':{
        target:'http://192.168.1.72:8084',
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/nyuwa/,'')
      }
    }
  }

})
